<template>
  <div class="main">
    <div class="container">
      <h1>欢迎使用todo-list</h1>
      <TodoAdd :todos="todos" @addTodo="addTodo"></TodoAdd>
      <TodoFilter
        :selected="filter"
        @changeFilter="filter = $event"
      ></TodoFilter>
      <TodoList :todos="filteredTodos" :delTodo="delTodo"></TodoList>
    </div>
  </div>
</template>

<script>
import TodoAdd from './components/TodoAdd.vue';
import TodoFilter from './components/TodoFilter.vue';
import TodoList from './components/TodoList.vue';
import useTodos from './composables/useTodos';
import useFilteredTodos from './composables/useFilteredTodos';

export default {
  name: 'App',
  components: {
    TodoAdd,
    TodoFilter,
    TodoList,
  },
  setup() {
    const { todos, addTodo, delTodo } = useTodos();
    const { filter, filteredTodos } = useFilteredTodos(todos);
    return {
      todos,
      addTodo,
      delTodo,
      filter,
      filteredTodos,
    };
  },
};
</script>

<style>
/* reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Helventica, "PingFang SC", "Microsoft Yahei", sans-serif;
}
li {
  list-style: none;
}
/* main */
.main {
  width: 100vw;
  min-height: 100vh;
  display: grid;
  place-items: center center;
  background-color: rgb(203, 210, 240);
}
/* container */
.container {
  width: 60%;
  max-width: 400px;
  padding: 48px 28px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.15);
  border-radius: 24px;
  background-color: rgb(245, 246, 252);
}
/* h1 */
h1 {
  margin: 24px 0;
  font-size: 28px;
  color: #414873;
}
</style>
